import { Injectable } from '@nestjs/common';
import { CreateTowerDto } from './dto/create-tower.dto';
import { UpdateTowerDto } from './dto/update-tower.dto';
import { PrismaService } from 'src/prisma/prisma.service';

@Injectable()
export class TowerService {
  constructor(private prisma: PrismaService) {}

  createMany(createTowerDtoArr: CreateTowerDto[]) {
    return this.prisma.tower.createMany({ data: createTowerDtoArr });
  }

  removeMany(id: number) {
    return this.prisma.tower.deleteMany({ where: { zoneId: id } });
  }

  async findAll(args: Record<string, any>) {
    const { zoneId } = args;
    const data = await this.prisma.tower.findMany({
      where: { zoneId: +zoneId },
      include: {
        pointTower: true,
      },
    });
    return data;
  }

  async findOne(id: number) {
    return await this.prisma.tower.findUnique({ where: { id } });
  }

  update(id: number, updateTowerDto: UpdateTowerDto) {
    return `This action updates a #${id} tower`;
  }

  remove(id: number) {
    return `This action removes a #${id} tower`;
  }
}
